package JZOffer;

// 链表中倒数第k个节点
public class JzOffer22 {
    public ListNode getKthFromEnd(ListNode head, int k) {
        ListNode left = head;
        ListNode right = head;

        for (int i = 0; i < k; i++) {
            left = left.next;
        }

        while (left != null) {
            left = left.next;
            right = right.next;
        }
        return right;
    }
}
